﻿using System;
using System.Configuration;


namespace FireBus.Core.Configuration
{
	public class ExtensionTokenElementCollection : ConfigurationElementCollection
	{
		protected override ConfigurationElement CreateNewElement()
		{
			return new ExtensionTokenElement();
		}

		protected override Object GetElementKey(ConfigurationElement element)
		{
			return ((ExtensionTokenElement)element).Name;
		}

		public override ConfigurationElementCollectionType CollectionType
		{
			get { return ConfigurationElementCollectionType.BasicMap; }
		}

		protected override String ElementName
		{
			get { return "extensionToken"; }
		}

		public ExtensionTokenElement this[int index]
		{
			get
			{
				return (ExtensionTokenElement)BaseGet(index);
			}
			set
			{
				if (BaseGet(index) != null)
				{
					BaseRemoveAt(index);
				}
				BaseAdd(index, value);
			}
		}

		new public ExtensionTokenElement this[String name]
		{
			get { return (ExtensionTokenElement)BaseGet(name); }
		}

		public Boolean ContainsKey(string key)
		{
			return BaseGet(key) != null;
		}
	}
}
